<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var fun=function(x){
				let n1=document.getElementById("num1").value;
				let n2=document.getElementById("num2").value;
				if(isNaN(n1)||isNaN(n2)){
				     alert("输入内容不是数字！");
					 return;
				}
				document.getElementById("num3").value=eval(n1+x+n2);
				}
		</script>
	</head>
	<body>
		第一个数：<input type="text" id="num1"/><br>
		第二个数：<input type="text" id="num2"/><br>
		<button type="button" onclick="fun('+')">+</button>
		<button type="button" onclick="fun('-')">-</button>
		<button type="button" onclick="fun('*')">*</button>
		<button type="button" onclick="fun('/')">/</button><br>
		计算结果：<input type="text" id="num3"/>
	</body>
</html>
